package com.example.day06.dao;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

@Component
@Slf4j
public class JdbcCourseMapper {
    public void login(String username, String password)  {
        try{
            Class.forName("com.mysql.cj.jdbc.Driver");
            Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/day06", "root", "root");
            Statement statement = conn.createStatement();
            //唯一不一样
            String sql="select * from tb_student where name='" + username + "' and no='" + password + "'";
            System.out.println(sql);
            ResultSet resultSet = statement.executeQuery(sql);

            while (resultSet.next()){
                String name = resultSet.getString("name");
                System.out.println(name);
            }


        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
